package com.baidu.dao;

import com.baidu.pojo.CheckGroup;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface CheckGroupDao {

    Page<CheckGroup> findAllByGroup(String queryString);

    int addByCheckGroup(CheckGroup checkGroup);

    @Insert("insert into t_checkgroup_checkitem(checkgroup_id, checkitem_id) values(#{groupId}, #{checkitemId})")
    void addByCheckGroupAndCheckItem(@Param("groupId")Integer groupId, @Param("checkitemId") Integer checkitemId);

    @Select("select * from t_checkgroup where id = #{id}")
    CheckGroup findAllByGroupId(int id);

    int update(CheckGroup checkGroup);

    @Select("select count(0) from t_checkgroup_checkitem where checkgroup_id = #{id}")
    int findByGroupAndItem(int id);
    @Delete("delete from t_checkgroup where id = #{id}")
    int delete(int id);

    List<CheckGroup> findAll();
}
